# -*- coding:utf-8 -*-
import MySQLdb
import config

class mysqlhelper(object):
    def __init__(self):
        self.__conn = config.conn
        
    def get_dict(self,sql,params=0):
        conn = MySQLdb.connect(**self.__conn)
        cur = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
        sql = cur.execute(sql,params)   
        data = cur.fetchall()  
        cur.close()   
        conn.close()   
        return data
    
    def get_one(self,sql,params):
        conn = MySQLdb.connect(**self.__conn)
        cur = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
        sql = cur.execute(sql,params)   
        data = cur.fetchone()  
        cur.close()   
        conn.close()   
        return data

